package com.idatax.auth.controller;

import com.idatax.auth.common.jwt.JwkKeyService;
import com.nimbusds.jose.jwk.JWKSet;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/.well-known")
public class JwkSetController {
    private final JwkKeyService jwkKeyService;

    public JwkSetController(JwkKeyService jwkKeyService) {
        this.jwkKeyService = jwkKeyService;
    }

    @GetMapping("/jwks.json")
    public String getJwkSet() {
        JWKSet jwkSet = jwkKeyService.getJwkSet();
        return jwkSet.toString();
    }
}
